<script lang="ts" setup>
import { ref } from 'vue'
import { GetDetailData } from '@/api/modules/membersignin'

// const imgDomain = 'https://img1.eprhan.cc'
const route = useRoute()
const router = useRouter()

const dataList: any = reactive({
  list: [],
})
const loading = ref(true)
const total = ref(0)

async function GetDataList(PageIndex: number = 1, PageSize: number = 20) {
  const params = {
    PageIndex,
    PageSize,
    SigninId: route.query.SigninId,
  }
  await GetDetailData(params).then(async (dataRes: any) => {
    if (dataRes.succeeded) {
      dataList.list = dataRes.data.items
      total.value = dataRes.data.total

      loading.value = false
    }
  })
}

// 返回用户列表
function Backtrack() {
  router.push({
    name: 'membersigninIndex',
  })
}

// 翻页
const PageSize = ref(20)
function handleSizeChange(val: number) {
  GetDataList(1, val)
  PageSize.value = val
}
function handleCurrentChange(val: number) {
  GetDataList(val, PageSize.value)
}

onMounted(() => {
  GetDataList()
})
</script>

<template>
  <div>
    <PageMain>
      <!-- <SearchBar :show-toggle="false">
        <div class="header">
          <el-form label-positio="right" label-width="auto">
            <div class="from">
              <el-form-item label="用户ID">
                <el-input v-model="findFrom.UserId" placeholder="请输入用户ID" clearable />
              </el-form-item>
              <el-form-item label="手机号">
                <el-input v-model="findFrom.Mobile" placeholder="请输入手机号" clearable />
              </el-form-item>
            </div>
          </el-form>
          <div class="text-right">
            <el-button @click="Inquire">
              查询
            </el-button>
          </div>
        </div>
      </SearchBar> -->
      <!-- <ElDivider border-style="dashed" /> -->
      <div class="mb-5 text-right">
        <el-button type="success" @click="Backtrack">
          返回用户列表
        </el-button>
      </div>
      <el-table v-loading="loading" :data="dataList.list" stripe style="width: 100%;" border>
        <el-table-column align="center" prop="signinId" label="签到用户ID" width="100" />
        <el-table-column align="center" prop="signinDate" label="签到日期" width="220" />
        <el-table-column align="center" prop="signinTimes" label="连续签到天数" width="220" />
        <el-table-column align="center" prop="signinCode" label="签到流水号" width="160" />
        <el-table-column align="center" prop="score" label="签到获取的总积分数" width="200" />
        <el-table-column align="center" prop="addtime" label="签到时间" width="200" />
      </el-table>
      <div style="height: 10px;" />
      <el-pagination
        :default-page-size="20"
        :page-sizes="[5, 10, 20, 50, 100]"
        layout="total, sizes, ->, prev, pager, next, jumper"
        :total="total"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
      />
    </PageMain>
  </div>
</template>

<style scoped>
.header {
  display: grid;
  grid-template-columns: 6fr 1fr;

  .from {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    grid-gap: 20px;

    .el-form-item {
      margin-bottom: 0;
    }
  }
}

.user-name {
  display: flex;
  align-items: center;
  justify-content: left;
  margin-right: 25px;

  div {
    text-align: left;
  }
}
</style>
